﻿using Sharp.Infrastructure;
using Sharp.Infrastructure.Network;
using StockTools.Configuration;
using StockTools.Model;
using StockTools.ViewModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace StockTools
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainViewModel _mainViewModel;
        public MainWindow()
        {
            InitializeComponent();
            _mainViewModel = new MainViewModel();

            this.DataContext = _mainViewModel;

            this.MouseLeftButtonDown += Window_MouseLeftButtonDown;
            this.ResizeMode = System.Windows.ResizeMode.CanMinimize;
        }
           

        protected override void OnKeyDown(KeyEventArgs e)
        {
            TraversalRequest request;
            if (e.Key == Key.Enter )
            {
                request = new TraversalRequest(FocusNavigationDirection.Next);
                UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;

                if (elementWithFocus != null)
                {
                    elementWithFocus.MoveFocus(request);
                }
                e.Handled = true;
            }


            base.OnKeyDown(e);
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }
    }
}